<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<script src="../../resources/js-test.js"> </script>
<script>
window.jsTestIsAsync = true;

function test() {
    document.forms.f.submit();
}
</script>
<body onload="test()">
<p>Test that when dirname attribute is specified then it is added in submission body.</p>

<form action="#action" name="f">
    <p><label>Comment: <input type=text name="comment" dirname="comment.dir" required></label></p>
    <p><label>WithRTLDir: <textarea name="txtarea" dir="rtl" dirname="txtareaRTL.dir"></textarea></label></p>
    <p><label>WithLTRDir: <textarea name="txtarea1" dir="ltr" dirname="txtareaLTR.dir"></textarea></label></p>
    <p><label>WithInvalidDir: <textarea name="txtarea2" dir="invalid" dirname="txtareaInvalid.dir"></textarea></label></p>
    <p><label>WithRTLValue: <input name="input" dirname="inputRTLvalue.dir" value="مرحبًا"></label></p>
    <p><button name="mode" type=submit value="add">Post Comment</button></p>
</form>

<div id="console"></div>
<div id="action">
<script>
if (document.location.href.match('\\?')) {
    shouldBeTrue('document.location.search.indexOf("comment.dir=ltr") != -1');
    shouldBeTrue('document.location.search.indexOf("txtareaRTL.dir=rtl") != -1');
    shouldBeTrue('document.location.search.indexOf("txtareaLTR.dir=ltr") != -1');
    shouldBeTrue('document.location.search.indexOf("txtareaInvalid.dir=ltr") != -1');
    shouldBeTrue('document.location.search.indexOf("inputRTLvalue.dir=ltr") != -1');
    finishJSTest();
}

successfullyParsed = true;
</script>
</div>
</body>
</html>
